<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><{:C('web_site_name')}>---系统用户编辑</title>
<link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/common.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/main.css"/>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/lib.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/layer.min.js"></script>
<style>

</style>
</head>
<body>


<form id="info_form" action="<?php echo  U("sysadmin/edit" , array('action'=>'doedit' , 'showpage'=>1 ) ) ; ?>" method="post">
<input type="hidden" name="id" value="<?php echo $info['id']?>">
<div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i>首页<span class="crumb-step">&gt;</span><span class="crumb-name">系统用户</span></div>
        </div>
        
        <div class="result-wrap">
            <div class="result-content">
                    <table class="insert-tab" width="100%">
                        <tbody>
                            <tr>
                                <th><i class="require-red">*</i>用户名字：</th>
                                <td>
                                    <input class="common-text required" id="username" disabled name="username" size="40" value="<?php echo $info['username']?>" type="text">
                                </td>
                            </tr>
                           <tr>
                                <th><i class="require-red">*</i>用户昵称：</th>
                                <td>
                                    <input class="common-text required" id="nick" name="nick" size="40" value="<?php echo $info['nick']?>" type="text"><i>必填</i>
                                </td>
                            </tr>  
                          
                            <tr>
                                <th>是否是超级管理员：</th>
                                <td>
                                <input type="radio" name="super_admin" value="1" onclick="super_admin_(1);"/> 是
           <input type="radio" name="super_admin" value="0" onclick="super_admin_(0);" checked/> 不是
                                </td>
                            </tr>
                             <tr>
                                <th>所属组：</th>
                                <td>
                                	<select name="gid">
				<?php 
					if(isset($list) && $list){
						foreach($list as $k_=>$v_){
					
				?>
				<option value="<?php echo $v_['id'];?>" <?php if($info['gid'] == $v_['id']){echo "selected='selected'";}?>><?php echo $v_['rolename'];?></option>
				<?php 
						}	
					}
				?>
	</select>
                                </td>
                            </tr>
                            <tr id="group_">
                                <th><i class="require-red">*</i>用户组：</th>
                                <td>
<select name="gid1" style="width:300px ; height:500px" size="310" id="select1">
				<?php 
				
					if(isset($options) && $options){
						foreach($options as $k_=>$v_){
					
				?>
				<option value="<?php echo isset( $v_['url'] )?$v_['url']:''; ?>"><?php echo str_repeat("----", $v_['deep']). $v_['name'];?></option>
				<?php 
						}	
					}
				?>
			</select>
			<div id="choose" style="float:right ; width:70%;border:solid 1px">
			<div>已经添加的权限组：</div>
			<?php 

				if(isset($perm_array_exists) && $perm_array_exists){
					foreach($perm_array_exists as $p_=>$v_ ){
						echo "<span><font color='red'>".$v_."</font><input type='checkbox' name='p[]' value='{$p_}' checked='checked' onclick=\"del_o(this)\"></span>";
					}
				}
			?>
			</div>
                                </td>
                            </tr>
                            <tr>
                                <th>状态：</th>
                                <td>
                                <input type="radio" name="status" value="1" checked/> 启用
    <input type="radio" name="status" value="0"/> 禁用
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                                </td>
                            </tr>
                        </tbody></table>
            </div>
        </div>
       
      </form>  
    
   </body>
   </html>    
  <script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/formvalidator.js"></script> 
<script>
<?php
		$perms_ = '[' ;
		if(isset($perm_array_exists) && $perm_array_exists){
			foreach($perm_array_exists as $k1=>$v1){
				$perms_.='\''.$k1.'\',';
			}
			$perms_ = rtrim($perms_,",");
		}
		$perms_.=']';
?>
var exists_perms = <?php echo $perms_ ;?> ;
function super_admin_(type){
	if(type == 1 ){
		$("#group_").hide();
	}else{
		$("#group_").show();
	}
}
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
	$("#nick").formValidator({onshow:'昵称必填',onfocus:'请填写昵称'}).inputValidator({min:1,onerror:'请填写昵称'});
	$('#select1').dblclick(function(){ //绑定双击事件
		var value = $("option:selected",this).val(); //获取选中的值
		var text = $("option:selected",this).text() ;
		text = text.replace(/-/g,"");
	
		if(value && !in_array(value,exists_perms)){
			$("#choose").append("<span><font color='green' >"+text+"</font><input type='checkbox' value='"+value+"' name='p[]' checked='true' onclick='del_o(this)'></span>&nbsp;");
			exists_perms.push(value);
			
		}
	});
});
function in_array(needle, haystack) {
	if(typeof needle == 'string' || typeof needle == 'number') {
		for(var i in haystack) {
			if(haystack[i] == needle) {
					return true;
			}
		}
	}
	return false;
}
//删除checkbox
function del_o(o){
	o = $(o);//转化为jquery对象
	if(!o.is(":checked")){
		o.parent().remove();
	}
}
</script>
        